/**
 * 
 */
package com.disys.facade;

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;

import com.disys.dao.Rec150erticswksiteDAO;
import com.disys.model.Rec140ERWOTCLOC;
import com.disys.model.Rec150erticswksite;

/**
 * @author Ubaid Raja
 *
 */
public class Rec150erticswksiteFacade {
private Rec150erticswksiteDAO obj = new Rec150erticswksiteDAO();
	
	public List<Rec150erticswksite> findAllRecords(){
		
		List<Rec150erticswksite> list = null;
		try{
			obj.beginTransaction();	
			list = obj.findAll();
			obj.closeTransaction();
		}catch(IllegalStateException ex){
			list = obj.findAllSorted("Process");
			obj.closeTransaction();
		}
		if(list.size() ==0 || list == null){
			return new ArrayList<Rec150erticswksite>();
		}
		return list;
		
	}
	
	public void insertRecord(Rec150erticswksite entity){
		obj.beginTransaction();
		obj.save(entity);
		obj.commit();
	}
	
	public List<Rec150erticswksite> findFinalizeRecords(String object,Integer isFinalized,BigInteger pId){
		//obj.beginTransaction();
		List<Rec150erticswksite> list = obj.findFinalizeRecords(object,isFinalized,pId);
		//obj.closeTransaction();
		if(list.size() ==0 || list == null){
			return new ArrayList<Rec150erticswksite>();
		}
		return list;
	}
	
	public List<Integer> getAllProcessIds(String object) {
		obj.beginTransaction();
		List<Integer> list = obj.getAllProcessIds(object);
		obj.closeTransaction();
		return list;
	}
	
	public List<Rec150erticswksite> findSelectedProcessRecords(String object,BigInteger processId){
		List<Rec150erticswksite> list = null;
			obj.beginTransaction();	
			list = obj.findSelectedProcessRecords(object,processId);
			obj.closeTransaction();
		if(list.size() ==0 || list == null){
			return new ArrayList<Rec150erticswksite>();
		}
		return list;
	}
}
